var db=require("../db/db.js");
var express=require("express");
var router=require('vue-router')
var app=express();
var bodyParser=require("body-parser");
const { request, response } = require("express");
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
var router=express.Router();
router.get("/loginreq",(request,response)=>{
    

    var ret=request.query
    
    db.User.find(ret).then(res=>{
   
        if(res!=''){
            response.send("1");
            //console.log(res)
        }
        else{
            response.send("0")
        }
       
    })
});
router.get("/registreq",(request,response)=>{
    //db.Artical.bulkWrite([{updateMany:{filter:{},update:{$set:{username:request.query.username}},upsert:1}}])
    // db.Artical.find().then(res=>{
    //     console.log(res)
    // })
    new db.User(request.query).save().then(res=>{
        response.send("1");
    }).catch(err=>{
        response.send("0")
    })

})



module.exports=router;